/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pos.system.database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author shameera
 */
@Deprecated
public class ConnectMysql {

    private String url = "jdbc:mysql://localhost:3306/pos_db";
    private String username = "admin";
    private String password = "admin";
    
    Connection conn ;
    Statement stat;
    public ConnectMysql() throws SQLException {
        conn = DriverManager.getConnection(url , username , password);
        stat = conn.createStatement();
    }
    
    public void close() throws SQLException{
        conn.close();
    }
    
    public ResultSet executeSelect(String mysqlQuery) throws SQLException{
        return stat.executeQuery(mysqlQuery);
        
    }

    public int executeQuery(String mysqlQuery) throws SQLException{
        return stat.executeUpdate(mysqlQuery);
    }
    public static void main(String[] args) {  
        try {  
            Class.forName("com.mysql.jdbc.Driver");  
            Connection connection = DriverManager.getConnection(  
                    "jdbc:mysql://localhost:3306/pos_db", "admin", "admin");  
            Statement statement = connection.createStatement(); 
//            ResultSet resultSet = statement.executeQuery("INSERT INTO `pos_db`.`quick_pos` (`Stock` ,`Code` ,`Description` ,`Price` ,`Discount` ,`Quantity` ,`Amount`)VALUES ('vegi_3', '3', 'sample entry_3', '234', '45', '345', '23');");  
//            while (resultSet.next()) {  
//                System.out.println("Code :" + resultSet.getString("Code"));
//                
//            }  
            statement.executeUpdate("INSERT INTO `pos_db`.`quick_pos` (`Stock` ,`Code` ,`Description` ,`Price` ,`Discount` ,`Quantity` ,`Amount`)VALUES ('vegi_4', '4', 'sample entry_4', '234', '45', '345', '23');");  

        } catch (Exception e) {  
            e.printStackTrace();  
        }  
    }
    
}
